package com.wq.sofa.framework.rpc.client;

import com.wq.sofa.framework.service.common.HelloExampleService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ImportResource;

@ImportResource({"classpath*:sofa-client-config.xml"})
@SpringBootApplication
public class SofaRpcBootClientDemoApplication {

    public static void main(String[] args) {
//        禁用springboot的热部署,参考【https://www.jianshu.com/p/e6d5a3969343】
        System.setProperty("spring.devtools.restart.enabled","false");
        ApplicationContext applicationContext = SpringApplication.run(SofaRpcBootClientDemoApplication.class, args);
        HelloExampleService helloExampleService = (HelloExampleService) applicationContext.getBean("helloExampleServiceClient");
//        可以通过对比HelloExampleService这个类以及代理对象helloExampleService的类加载器
//        System.out.println(helloExampleService.getClass().getClassLoader());
//        System.out.println(HelloExampleService.class.getClassLoader());
        System.out.println("sofa-rpc response");
        System.out.println(helloExampleService.saySync("hello"));
        helloExampleService.saySync("hello");

//        System.out.println("直连调用");
//        HelloExampleService strightCall = (HelloExampleService) applicationContext.getBean("strightConnectService");
//        strightCall.saySync("直连调用");
    }
}
